package be.sc.classicnetwork.util;

import java.io.IOException;
import java.util.Properties;

import be.sc.classicnetwork.exception.ApplicationException;

/**
 * PropertiesUtils.
 */
public abstract class PropertiesUtils {

	private static Properties applicationProperties;

	public static final String IMAGE_MAX_WIDTH;

	public static final String IMAGE_THUMB_WIDTH;

	public static final String MAX_PAGE_ITEMS;

	public static final String MAIL_FROM;

	public static final String MAIL_FROM_PERSONAL;

	public static final String MAIL_SUBJECT_PREFIX;

	static {
		applicationProperties = new Properties();
		try {
			applicationProperties.load(Utils.class
					.getResourceAsStream("/application.properties"));
		} catch (IOException e) {
			throw new ApplicationException(e);
		}

		IMAGE_MAX_WIDTH = get("classicnetwork.imageMaxWidth");
		IMAGE_THUMB_WIDTH = get("classicnetwork.imageThumbWidth");
		MAX_PAGE_ITEMS = get("classicnetwork.maxPageItems");
		MAIL_FROM = get("mail.from");
		MAIL_FROM_PERSONAL = get("mail.fromPersonal");
		MAIL_SUBJECT_PREFIX = get("mail.subjectPrefix");
	}

	/**
	 * Gets properties from application.properties.
	 */
	public static String get(String property) {
		return applicationProperties.getProperty(property);
	}
}
